<?php
namespace app;

// 应用请求对象类
use basic\traits\Macro;

/**
 * Class Request
 * @method token() token消息
 * @method isLogin() 是否已登录
 * @method uid() 用户id
 * @method userInfo() 用户信息
 * @package app
 */
class Request extends \think\Request
{
    use Macro;

    public function __construct()
    {
        parent::__construct();
    }

    public function params($params): array
    {
        $data = [];
        foreach ($params as $param){
            if(!is_array($param) && $param != '')
                $data[$param] = $this->param($param,'');
            if(is_array($param) && count($param)) {
                $data[$param[0]] = $this->param($param[0]) ?? ($param[1]??'');
            }
        }
        return $data;
    }

    public function page()
    {
        $page = $this->param('page',1);
        $limit = $this->param('limit',10);
        if($limit>100) $limit = 100;
        return [(int) $page,(int) $limit];
    }

}
